use std::{sync::mpsc::channel, thread};

fn main() {
    let (tx, rx) = channel();
    let t = thread::spawn(move || {
        while let Ok(n) = rx.recv() {
            println!("Received: {}", n);
            if n == 9 {
                break;
            }
        }
    });
    for i in 0..10 {
        tx.send(i).unwrap();
    }

    t.join().unwrap();
}
